package com.qfedu.microlottery.record.consumer;

import com.alibaba.fastjson.JSON;
import com.qfedu.common.core.entity.Lotteryrecord;
import com.qfedu.microlottery.record.service.LotteryrecordService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Classname LotteryConsumer
 * @Description TODO
 * @Date 2025-10-09 16:15
 * @Created by 老任与码
 */
@Component
@RocketMQMessageListener(topic = "lottery_topic", consumerGroup = "lottery_group")
public class LotteryConsumer implements RocketMQListener<String> {
    @Resource
    private LotteryrecordService lotteryrecordService;

    @Override
    public void onMessage(String s) {
        Lotteryrecord lotteryrecord = JSON.parseObject(s, Lotteryrecord.class);
        lotteryrecordService.addRecord(lotteryrecord);
    }
}
